<template>
  <div>
    <div style="height:100%; width:100%; margin: 10px 0; color: #ff9999">
      <label-wrap>假装这有一个搜索栏</label-wrap>
    </div>
    <el-card class="filter-container" shadow="never">
    <div style="height:100%; width:100%; margin: 10px 0">
<!--      <el-carousel height="450px" :interval="10000">-->
<!--        <el-carousel-item v-for="item in imgs" :key="item">-->
<!--          <img :src="item" alt="" style="width: 100%">-->
<!--        </el-carousel-item>-->
<!--      </el-carousel>-->
      <el-carousel :interval="10000" type="card">
        <el-carousel-item v-for="item in imgs" :key="item">
          <img :src="item" style="width: 100%;border-radius: 10px">
        </el-carousel-item>
      </el-carousel>
    </div>
<!--    <div style="margin: 10px 0">-->
<!--      <el-row :gutter="10">-->
<!--        <el-col :span="6" v-for="item in files" :key="item.id" style="margin-bottom: 10px">-->
<!--          <div style="border: 1px solid #ccc; padding-bottom: 10px">-->
<!--            <img :src="item" alt="" style="height: 150px;width: 100%">-->
<!--            <div style="color: #666; padding: 10px"></div>-->
<!--            <div style="padding: 10px"></div>-->
<!--            <div style="padding: 10px" class="button-group">-->
<!--              <el-button type="success">购买</el-button>-->
<!--              <el-button type="primary">商品详情</el-button>-->
<!--            </div>-->
<!--          </div>-->
<!--        </el-col>-->
<!--      </el-row>-->
<!--    </div>-->
    <div style="margin: 10px 0">
      <el-row :gutter="10">
        <el-col :span="6" v-for="item in tableData" :key="item.id" style="margin-bottom: 10px">
          <div style="border: 1px solid #ccc; padding-bottom: 10px; border-radius: 10px; overflow: hidden">
            <img :src="item.pic" alt="" style="width: 100%; cursor: pointer" @click="$router.push('/front/detail?id=' + item.id)">
            <div style="color: #666; padding: 5px; font-size: 18px; cursor: pointer"><b @click="$router.push('/front/detail?id=' + item.id)">{{ item.name }}</b></div>
            <div style="color: #666; padding: 5px; font-size: 14px">{{ item.description }}</div>
            <div style="padding: 5px; font-size: 14px; color: orangered">￥ {{ item.price }}</div>
          </div>
        </el-col>
      </el-row>
    </div>
    <div style="padding: 10px 0">
      <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="pageNum"
          :page-sizes="[2, 5, 10, 20]"
          :page-size="pageSize"
          layout="total, prev, pager, next"
          :total="total">
      </el-pagination>
    </div>
    </el-card>
    <!--    footer-->
    <div class="footer">
    </div>
    <!--    footer-->

  </div>
</template>


<script>
export default {
  name: "FrontHome",
  data() {
    return {
      imgs: [
          'https://s2.loli.net/2022/06/16/tiMfu8RjFoxVSdN.png',
          'https://s2.loli.net/2022/06/16/cze7GWlqRPosXpM.jpg',
          'https://s2.loli.net/2022/06/16/pum1TjOVXabChS3.png'

      ],
      files:[
        'https://s2.loli.net/2022/06/16/pum1TjOVXabChS3.png',
        'https://s2.loli.net/2022/06/16/jNQxfng4zwCXvOV.png',
        'https://s2.loli.net/2022/06/16/R4ymn7rdu8YCvIk.png',
        'https://s2.loli.net/2022/06/16/VdpnmBfsA7RM1uS.png',
        'https://s2.loli.net/2022/06/16/pum1TjOVXabChS3.png',
        'https://s2.loli.net/2022/06/16/jNQxfng4zwCXvOV.png',
        'https://s2.loli.net/2022/06/16/R4ymn7rdu8YCvIk.png',
        'https://s2.loli.net/2022/06/16/VdpnmBfsA7RM1uS.png',
        'https://s2.loli.net/2022/06/16/pum1TjOVXabChS3.png',
        'https://s2.loli.net/2022/06/16/jNQxfng4zwCXvOV.png',
        'https://s2.loli.net/2022/06/16/R4ymn7rdu8YCvIk.png',
        'https://s2.loli.net/2022/06/16/VdpnmBfsA7RM1uS.png',
        'https://s2.loli.net/2022/06/16/pum1TjOVXabChS3.png',
        'https://s2.loli.net/2022/06/16/jNQxfng4zwCXvOV.png',
        'https://s2.loli.net/2022/06/16/R4ymn7rdu8YCvIk.png',
        'https://s2.loli.net/2022/06/16/VdpnmBfsA7RM1uS.png',
        'https://s2.loli.net/2022/06/16/pum1TjOVXabChS3.png',
        'https://s2.loli.net/2022/06/16/jNQxfng4zwCXvOV.png',
        'https://s2.loli.net/2022/06/16/R4ymn7rdu8YCvIk.png',
        'https://s2.loli.net/2022/06/16/VdpnmBfsA7RM1uS.png',
        'https://s2.loli.net/2022/06/16/pum1TjOVXabChS3.png',
        'https://s2.loli.net/2022/06/16/jNQxfng4zwCXvOV.png',
        'https://s2.loli.net/2022/06/16/R4ymn7rdu8YCvIk.png',
        'https://s2.loli.net/2022/06/16/VdpnmBfsA7RM1uS.png',
        'https://s2.loli.net/2022/06/16/pum1TjOVXabChS3.png',
        'https://s2.loli.net/2022/06/16/jNQxfng4zwCXvOV.png',
        'https://s2.loli.net/2022/06/16/R4ymn7rdu8YCvIk.png',
        'https://s2.loli.net/2022/06/16/VdpnmBfsA7RM1uS.png',
        'https://s2.loli.net/2022/06/16/pum1TjOVXabChS3.png',
        'https://s2.loli.net/2022/06/16/jNQxfng4zwCXvOV.png',
        'https://s2.loli.net/2022/06/16/R4ymn7rdu8YCvIk.png',
        'https://s2.loli.net/2022/06/16/VdpnmBfsA7RM1uS.png'
      ],
      tableData: [],
      total: 0,
      pageNum: 1,
      pageSize: 10,
      name: "",
    }
  },
  created() {
    this.load()  // 获取后台的商品数据
  },
  methods: {
    load() {
      this.request.get("/product/list", {
        params: {
          pageNum: this.pageNum,
          pageSize: this.pageSize,
          name: this.name,
        }
      }).then(res => {
        this.tableData = res.data.records
        this.total = res.data.total
      })
    },
    handleSizeChange(pageSize) {
      console.log(pageSize)
      this.pageSize = pageSize
      this.load()
    },
    handleCurrentChange(pageNum) {
      console.log(pageNum)
      this.pageNum = pageNum
      this.load()
    },
  }
}
</script>

<style scoped>
  .button-group{
    display: flex;
    justify-content: space-between;
  }
</style>
